Generally a comparator is a device that compares two voltages or currents and outputs a digital signal indicating which is larger. In other words, as the name suggests, a comparator compares an analog signal with another analog signal and outputs a binary signal based on the comparison. The comparator can be thought of as a decision-making circuit.
Comparators are generally classified as open-loop comparators and regenerative comparators. Comparators are generally used in open-loop mode and so it is not necessary to compensate the comparator. Open-loop comparators are basically operational amplifiers without compensation. Since no compensation is needed, it has the largest bandwidth possible which gives a faster response. Since comparators are generally used in open loop mode, they can have very high open-loop gain. Regenerative comparators use positive feedback, similar to sense amplifiers or flip-flops, to accomplish the comparison of the magnitude between two signals.
The comparator is widely used in the process of converting analog signals to digital signals, for example, in analog-digital converters, zero crossing detectors, null detectors, relaxation oscillators, level shifters, window detectors, and others.
While it is easy to understand the basic task of a comparator, that is, comparing two voltages or currents, several parameters must be considered while selecting a suitable comparator. For example, comparators generally are designed to operate more optimally than op-amps in digital applications, in that comparator output voltages will go very close to the power supply voltage rails and their outputs will swing between these rails very fast, that is they have a very high slew rate. Other parameters that are important for comparators include gain, propagation delay, input offset, and others.
One problem with comparators is that the input signal is often corrupted with noise and/or may be very slowly changing. A comparator normally changes its output state when the voltage between its inputs crosses through approximately zero volts, for example, when using the comparator as a zero-crossing detector. Small voltage fluctuations due to noise that are always present on the inputs can cause undesirable rapid changes between the two output states when the input voltage difference is near zero volts. This noise can cause output glitches that consume a lot of power.
To prevent this output oscillation, a small hysteresis of a few millivolts is integrated into many modern comparators. In place of one switching point, hysteresis introduces two switching points.
When the input voltage drops to a lower reference voltage (a negative trip point), the output voltage changes from the high level state to a low level state. The comparator output voltage will remain in the low level state as the input voltage increases. When the input voltage reaches an upper reference voltage (a positive trip point), the output voltage will change from the low level state to the high level state. The difference between the positive trip point (VTRIP+) and the negative trip point (VTRIP−) equals the hysteresis voltage (VHYST). Such a bi-stable circuit is in effect a comparator with hysteresis. Such hysteresis may be introduced internally or using an external circuit.